package edu.jmu.utils;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import edu.jmu.bean.user.User;

/**
 * WEB工具类 
 * @author Neal
 *
 */
public class WebUtil extends ActionSupport{
	private static final long serialVersionUID = 6457815503601435157L;
	
	/**
	 * 获取验证码 
	 * @return	验证码(String类型）
	 */
	public static String getValidationCode(){
		return ActionContext.getContext().getSession().get("validationCode").toString();
	}
	/**
	 * 设置验证码
	 */
	public static void setValidationCode(String validationCode){
		ActionContext.getContext().getSession().put("validationCode",validationCode);
	}
	
	/**
	 * 设置用户Session
	 * @param user
	 */
	public static void setUser(User user){
		ActionContext.getContext().getSession().put("user", user);
	}
	/**
	 * 获得用户信息
	 * @return
	 */
	public static User getUser(){
		return (User)ActionContext.getContext().getSession().get("user");
	}
}
